*&---------------------------------------------------------------------*
*& 包含               ZPPR128_TOP
*&---------------------------------------------------------------------*
TABLES: proj , prps , resb,sscrfields .
DATA: BEGIN OF g_data,
        sel           TYPE char1,
        status        TYPE char4,
        message       TYPE char100,
        num           TYPE i,
        matnr_orgin   TYPE matnr,
        sernr_orgin   TYPE objk-sernr,
        charg_orgin   TYPE charg_d,
        aufnr_orgin   TYPE aufnr,
        matnr         TYPE matnr,
        sernr         TYPE objk-sernr,
        werks         TYPE werks_d,
        posid         TYPE ps_posid,
        order         TYPE aufnr,
        begda         TYPE datum,
        endda         TYPE datum,
        repair_reason TYPE char30,
        verid         TYPE verid, " 生产版本
        zzmodelcode   TYPE zzmodelcode, " 产品系列
        zzmodelnumber TYPE zzmodelnumber, " 产品代码
        zzprodline    TYPE zzprodline, " 产线
      END OF g_data.

DATA: gt_data LIKE TABLE OF g_data,
      gs_data LIKE LINE OF gt_data.

DATA     : gv_ucomm TYPE   sy-ucomm.
CONSTANTS: gc_green_light TYPE icon-id VALUE '@08@',
           gc_red_light   TYPE icon-id VALUE '@0A@'.
DATA: gt_excel LIKE TABLE OF zalsmex_tabline WITH HEADER LINE.

SELECTION-SCREEN PUSHBUTTON 2(15) bt1 USER-COMMAND download.

SELECTION-SCREEN  BEGIN OF LINE .
  SELECTION-SCREEN  PUSHBUTTON 2(15) bt2 USER-COMMAND upload .
  PARAMETERS p_file TYPE rlgrap-filename .
SELECTION-SCREEN  END OF LINE .

CLASS zcl_excel DEFINITION .

  PUBLIC SECTION.
    CLASS-METHODS:
      get_filename,
      download .
    METHODS:
      read_excel .

ENDCLASS .


CLASS zcl_data DEFINITION .

  PUBLIC SECTION .

    DATA: BEGIN OF l_operation,
            aufnr TYPE afko-aufnr, " 工单号
            vornr TYPE afvc-vornr, " 工序号
            ltxa1 TYPE afvc-ltxa1, " 工序短文本
            steus TYPE afvc-steus, " 工作重心
          END OF l_operation .
    DATA: mt_operation LIKE TABLE OF l_operation .

    DATA: BEGIN OF l_mblnr,
            mblnr TYPE mblnr,
            aufnr TYPE aufnr,
            cpudt TYPE budat,
            matnr TYPE matnr,
            werks TYPE werks_d,
            charg TYPE charg_d,
            sernr TYPE objk-sernr,
          END OF l_mblnr .
    DATA: mt_mblnr LIKE TABLE OF l_mblnr,
          ms_mblnr LIKE LINE OF mt_mblnr.

    DATA: mv_error   TYPE  char1,
          mv_message TYPE  char100.
    DATA: mv_plan_order TYPE plnum,
          mv_prod_order TYPE aufk-aufnr.
    DATA: ms_data LIKE gs_data.

    METHODS: constructor,
      query_and_check ,
      run ,
      create_planorder  ,
      bapi_plan_prod,
      bdc_plan_prod,
      add_operation ,
      add_component ,
      wait_and_removelock,
      call_bapi2  .

  PRIVATE SECTION .

ENDCLASS .

CLASS zcl_alv DEFINITION .

  PUBLIC SECTION .
    DATA:
      lt_fieldcat TYPE lvc_t_fcat,
      ls_fieldcat TYPE lvc_s_fcat,
      ls_layout_s TYPE lvc_s_layo,
      lt_exclude  TYPE ui_functions.

    METHODS:
      constructor IMPORTING io_data TYPE REF TO zcl_data,
      handle_toolbar
        FOR EVENT toolbar OF cl_gui_alv_grid
        IMPORTING e_object e_interactive,
      handle_user_command
        FOR EVENT user_command OF cl_gui_alv_grid
        IMPORTING e_ucomm,
      handle_data_changed
        FOR EVENT data_changed OF cl_gui_alv_grid
        IMPORTING er_data_changed ,
      handle_double_click
        FOR EVENT double_click OF cl_gui_alv_grid
        IMPORTING e_row e_column es_row_no ,
      register_event ,
      field_catalog ,
      display ,
      exclude_fun ,
      select_all_items,
      not_select_all_items ,
      add_field IMPORTING pv_field TYPE char30
                          pv_text  TYPE char30
                          pv_len   TYPE i
                          pv_check TYPE char1
                          pv_edit  TYPE char1
                .
  PRIVATE SECTION.
    DATA: lr_grid TYPE REF TO cl_gui_alv_grid.
    DATA: mo_data TYPE REF TO zcl_data.

ENDCLASS .


MODULE status_0900 OUTPUT.

  SET PF-STATUS 'STA_0900'.
  SET TITLEBAR 'TITLE_0900'.

ENDMODULE.
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0900  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE user_command_0900 INPUT.

  CASE gv_ucomm.
    WHEN 'BACK' OR 'EXIT'.
      LEAVE TO SCREEN 0.
    WHEN 'CANCEL'.
      LEAVE PROGRAM.
    WHEN OTHERS.
  ENDCASE.

ENDMODULE.